import * as CONSTANTS from '@/constants/index'
import QUIZSTATE from "@/store/state/quiz";

export default {
  [CONSTANTS.COMMIT_UPDATE_QUESTION_ACTIVEINDEX]: (state, payload) => {
    state['quiz']['currentQuestionIdx'] = payload
  },
  [CONSTANTS.COMMIT_UPDATE_HISTORYLIST]: (state, payload) => {
    state['quiz']['historyList'] = payload
  },
  [CONSTANTS.COMMIT_UPDATE_SHAREITEM]: (state, payload) => {
    state['quiz']['shareItem'] = payload
  },
  [CONSTANTS.COMMIT_UPDATE_COUNT]: (state, payload) => {
    state['quiz']['count'] = payload
  },
  [CONSTANTS.COMMIT_UPDATE_CANVASSRC]: (state, payload) => {
    state['quiz']['canvasSrc'] = payload
  },
  
  //第一页的历史记录数据
  [CONSTANTS.COMMIT_UPDATE_HISTORYLIST_LIST]: (state, payload) => {
    state['quiz']['historyList']['list'] = payload
  },
  //非第一页的历史记录数据
  [CONSTANTS.COMMIT_UPDATE_HISTORYLIST_TAILLIST]: (state, payload) => {
    let list = state['quiz']['historyList']['list']
    list.push(...payload)
    state['quiz']['historyList']['list'] = list
  },
  [CONSTANTS.COMMIT_UPDATE_HISTORYLIST_ISLOADING]: (state, payload) => {
    state['quiz']['historyList']['isLoading'] = payload
  },
  [CONSTANTS.COMMIT_UPDATE_HISTORYLIST_LASTESTITEM]: (state, payload) => {
    state['quiz']['historyList']['lastItem'] = payload
  },
  [CONSTANTS.COMMIT_UPDATE_HISTORYLIST_PAGENO]: (state, payload) => {
    state['quiz']['historyList']['pageNo'] = payload
  },
  [CONSTANTS.COMMIT_UPDATE_HISTORYLIST_TOTAL]: (state, payload) => {
    state['quiz']['historyList']['total'] = payload
  },
  [CONSTANTS.COMMIT_UPDATE_HISTORYLIST_TOTALPAGE]: (state, payload) => {
    state['quiz']['historyList']['totalPage'] = payload
  },
  //更新答题者的角色
  [CONSTANTS.COMMIT_UPDATE_QUIZ_ROLE]: (state, payload) => {
    state['quiz']['role'] = payload
  },

  //语言
  [CONSTANTS.COMMIT_UPDATE_QUESTIONS_LANGUAGE]: (state, payload) => {
    let list = state['quiz']['language']
    list.push(payload)
    state['quiz']['language'] = list
  },
  [CONSTANTS.COMMIT_UPDATE_QUESTIONS_LANGUAGESCORE]: (state, payload) => {
    state['quiz']['languageScore'] = payload
  },

  //逻辑
  [CONSTANTS.COMMIT_UPDATE_QUESTIONS_LOGIC]: (state, payload) => {
    // state["quiz"]['logic'] = payload;
    let list = state['quiz']['logic']
    list.push(payload)
    state['quiz']['logic'] = list
  },
  [CONSTANTS.COMMIT_UPDATE_QUESTIONS_LOGICSCORE]: (state, payload) => {
    state['quiz']['logicScore'] = payload
  },

  //空间
  [CONSTANTS.COMMIT_UPDATE_QUESTIONS_SPACE]: (state, payload) => {
    // state["quiz"]['space'] = payload;
    let list = state['quiz']['space']
    list.push(payload)
    state['quiz']['space'] = list
  },
  [CONSTANTS.COMMIT_UPDATE_QUESTIONS_SPACESCORE]: (state, payload) => {
    state['quiz']['spaceScore'] = payload
  },

  //运动
  [CONSTANTS.COMMIT_UPDATE_QUESTIONS_SPORT]: (state, payload) => {
    // state["quiz"]['sports'] = payload;
    let list = state['quiz']['sport']
    list.push(payload)
    state['quiz']['sport'] = list
  },
  [CONSTANTS.COMMIT_UPDATE_QUESTIONS_SPORTSCORE]: (state, payload) => {
    state['quiz']['sportsScore'] = payload
  },

  //音乐
  [CONSTANTS.COMMIT_UPDATE_QUESTIONS_MUSIC]: (state, payload) => {
    // state["quiz"]['music'] = payload;
    let list = state['quiz']['music']
    list.push(payload)
    state['quiz']['music'] = list
  },
  [CONSTANTS.COMMIT_UPDATE_QUESTIONS_MUSICSCORE]: (state, payload) => {
    state['quiz']['musicScore'] = payload
  },

  //人际
  [CONSTANTS.COMMIT_UPDATE_QUESTIONS_RELATIONSHIP]: (state, payload) => {
    // state["quiz"]['relationship'] = payload;
    let list = state['quiz']['relationship']
    list.push(payload)
    state['quiz']['relationship'] = list
  },
  [CONSTANTS.COMMIT_UPDATE_QUESTIONS_RELATIONSHIPSCORE]: (state, payload) => {
    state['quiz']['relationshipScore'] = payload
  },

  //自然
  [CONSTANTS.COMMIT_UPDATE_QUESTIONS_NATURE]: (state, payload) => {
    // state["quiz"]['natural'] = payload;
    let list = state['quiz']['nature']
    list.push(payload)
    state['quiz']['nature'] = list
  },
  [CONSTANTS.COMMIT_UPDATE_QUESTIONS_NATURESCORE]: (state, payload) => {
    state['quiz']['naturalScore'] = payload
  },

  //内省
  [CONSTANTS.COMMIT_UPDATE_QUESTIONS_INTROSPECTION]: (state, payload) => {
    // state["quiz"]['introspection'] = payload;
    let list = state['quiz']['introspection']
    list.push(payload)
    state['quiz']['introspection'] = list
  },
  [CONSTANTS.COMMIT_UPDATE_QUESTIONS_INTROSPECTIONSCORE]: (state, payload) => {
    state['quiz']['introspectionScore'] = payload
  },
  // RESET ALL QUIZ STATE
  [CONSTANTS.COMMIT_RESET_QUIZSTATE]: (state, payload) => {
    state['quiz'] = QUIZSTATE    
  },

}
